package front

import (
	"hft/Http/Services/front"
	utils "hft/Http/Utils"
	"strconv"

	"github.com/gin-gonic/gin"
)

type Index struct{}

func (*Index) GetIndex(c *gin.Context) {

	city, _ := strconv.Atoi(c.Request.Header.Get("sid"))

	info := front.IndexService.GetIndex(city)

	utils.OkWithData(info, c)
}

func (*Index) SEOList(c *gin.Context) {

	list := front.IndexService.SEOList()

	utils.OkWithData(list, c)

}

func (*Index) CheckLoginStatus(c *gin.Context) {
	token := c.Request.Header.Get("user-token")
	if uuid, err := front.IndexService.CheckLoginStatus(token); err != nil {
		utils.OkWithData(gin.H{"uuid": ""}, c)
	} else {
		utils.OkWithData(gin.H{"uuid": uuid}, c)
	}
}

var IndexController = new(Index)
